package com.lvmama.task.back.sweb;

import com.lvmama.comm.pet.po.perm.PermUser;
import com.lvmama.comm.utils.MemcachedUtil;
import com.lvmama.task.back.utils.WebUtils;
import com.lvmama.task.common.service.TaskOperationLogService;
import com.lvmama.task.common.service.TaskService;
import com.lvmama.task.common.utils.Constant;
import com.lvmama.task.common.utils.TaskUtil;
import com.lvmama.task.common.utils.TaskXmlModel;
import com.lvmama.task.common.utils.TaskXmlRoot;
import com.lvmama.task.common.vo.Task;
import com.lvmama.task.common.vo.TaskJobLog;
import com.lvmama.task.common.vo.TaskOperationLog;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.*;
import org.quartz.CronTrigger;
import org.quartz.TriggerUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by IntelliJ IDEA.<p/>
 * User: troy-kou<p/>
 * Date: 14-1-3<p/>
 * Time: 上午10:41<p/>
 * Email:kouhongyu@163.com<p/>
 */
@Namespace("/pub")
@SuppressWarnings("serial")
@ParentPackage("json-default")
@Results({
        @Result(name = "showTaskOperationLogDialog", location = "/WEB-INF/pages/back/task_operation_log_dialog.jsp"),
        @Result(name = "showTaskBatchModifyDialog", location = "/WEB-INF/pages/back/task_batch_modify_dialog.jsp"),
        @Result(name = "showTaskJobLogInfoDialog", location = "/WEB-INF/pages/back/task_job_log_info.jsp"),
        @Result(name = "showTaskJobLogDialog", location = "/WEB-INF/pages/back/task_job_log_dialog.jsp"),
        @Result(name = "showTaskDialog", location = "/WEB-INF/pages/back/task_dialog.jsp"),
        @Result(name = "toCopyTask", location = "/WEB-INF/pages/back/task_copy.jsp"),
        @Result(name = "toTaskOperationLogList", location = "/WEB-INF/pages/back/task_operation_log_list.jsp"),
        @Result(name = "toTaskBatchModifyEdit", location = "/WEB-INF/pages/back/task_batch_modify.jsp"),
        @Result(name = "toTaskJobLogList", location = "/WEB-INF/pages/back/task_job_log_list.jsp"),
        @Result(name = "toTaskList", location = "/WEB-INF/pages/back/task_list.jsp"),
        @Result(name = "editTask", location = "/WEB-INF/pages/back/task_edit.jsp"),
        @Result(name = "errorPage", location = "/WEB-INF/pages/back/error_page.jsp")
})
public class TaskAction extends BaseAction {

    private String taskName;
    private String status;
    private String available;
    private String cycle;
    private String jobNode;
    private String owner;
    private String lastRunStatus;
    private String taskNamePrefix;
    private String taskId;
    private String taskIds;
    private String serial;
    private String webServiceUrl;
    private String requestType;
    private String parameter;
    private String refreshQuery;
    private Task task;
    private TaskJobLog taskJobLog;

    private Map<String, Object> jsonMap = new HashMap<String, Object>();
    private List<Task> taskList;
    private List<TaskJobLog> taskJobLogList;
    private List<String> weeks;

    private TaskService taskService;
    private TaskOperationLogService taskOperationLogService;//日志操作

    private String errorInfo;
    private Integer copyCount;

    private File upload;
    private String message;
    private String selects;

    private Map paramMap = new HashMap();
    private List<TaskOperationLog> taskOperationLogList;
    private String taskJobLogId;
    private String resultRunStatus;
    private String startTime;
    private String endTime;
    private Constant.TIME_CONSUMING_MILLIS maxTimeConsuming;
    private Constant.TIME_CONSUMING_MILLIS minTimeConsuming;
    private String sort;
    private String sortField;

    @Action(value = "interrupt",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String interrupt() {
        try {

            String[] taskIdArr = taskIds.split(",");

            for (String taskIdStr : taskIdArr) {

                Long taskId = Long.parseLong(taskIdStr);
                task = taskService.getTask(taskId);

                Map<String, Object> paramMap = new HashMap<String, Object>();
                paramMap.put("taskId", task.getTaskId());
                paramMap.put("page", 1);
                paramMap.put("pageSize", 1);

                taskJobLogList = taskService.getTaskJobLogList(paramMap);
                if (taskJobLogList != null && taskJobLogList.size() > 0) {
                    taskJobLog = taskJobLogList.get(0);
                    String interruptKey = TaskUtil.generateInterruptKey(taskJobLog.getLogId());
                    /**
                     * 中断24小时
                     */
                    MemcachedUtil.getInstance().set(interruptKey, (24 * 60 * 60), taskJobLog.toString());
                }
            }

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value="showTaskDialog")
    public String showTaskDialog() {

        return "showTaskDialog";
    }

    @Action(value="showTaskJobLogInfoDialog")
    public String showTaskJobLogInfoDialog() {
        taskJobLog = taskService.getTaskJobLog(taskJobLog.getTaskJobLogId());

        return "showTaskJobLogInfoDialog";
    }

    @Action(value="showTaskJobLogListDialog")
    public String showTaskJobLogListDialog() {

        return "showTaskJobLogListDialog";
    }

    @Action(value="showTaskJobLogDialog")
    public String showTaskJobLogDialog() {

        return "showTaskJobLogDialog";
    }

    @Action(value="showTaskOperationLogDialog")
    public String showTaskOperationLogDialog() {

        return "showTaskOperationLogDialog";
    }

    @Action(value="showTaskBatchModifyDialog")
    public String showTaskBatchModifyDialog() {

        return "showTaskBatchModifyDialog";
    }

    @Action(value="copyTaskDialog")
    public String copyTaskDialog() {

        return "toCopyTask";
    }

    @Action(value="toTaskOperationLogList")
    public String toTaskOperationLogList() {

        paramMap.put("taskId", taskId);
        initPagination();
        pagination.setTotalRecords(taskOperationLogService.queryByObjectIdMapCount(paramMap));
        initPageSize();

        taskOperationLogList = taskOperationLogService.queryByObjectIdMap(paramMap);

        pagination.setActionUrl(WebUtils.getUrl(getRequest()));

        return "toTaskOperationLogList";
    }

    @Action(value="toTaskBatchModifyEdit")
    public String toTaskBatchModifyEdit() {

        return "toTaskBatchModifyEdit";
    }

    @Action(value="toTaskJobLogList")
    public String toTaskJobLogList() {

        Map<String, Object> paramMap = new HashMap<String, Object>();

        if (StringUtils.isNotBlank(taskId)) {
            paramMap.put("taskId", taskId);
        }
        if (StringUtils.isNotBlank(taskJobLogId)) {
            paramMap.put("taskJobLogId", taskJobLogId);
        }
        if (StringUtils.isNotBlank(resultRunStatus)) {
            paramMap.put("resultRunStatus", resultRunStatus);
        }
        if (StringUtils.isNotBlank(startTime)) {
            paramMap.put("startTime", startTime);
        }
        if (StringUtils.isNotBlank(endTime)) {
            paramMap.put("endTime", endTime);
        }
        if (maxTimeConsuming != null) {
            paramMap.put("maxTimeConsuming", maxTimeConsuming);
        }
         if (minTimeConsuming != null) {
            paramMap.put("minTimeConsuming", minTimeConsuming);
        }
        if (StringUtils.isNotBlank(sort)) {
            paramMap.put("sort", sort);
        }
        if (StringUtils.isNotBlank(sortField)) {
            paramMap.put("sortField", sortField);
        }
        pagination = super.initPagination();
        Long totalRowCount = taskService.getTaskJobLogCount(paramMap);

        paramMap.put("page", pagination.getPage());
        paramMap.put("pageSize", pagination.getPerPageRecord());

        taskJobLogList = taskService.getTaskJobLogList(paramMap);

        pagination.setTotalRecords(totalRowCount);
        pagination.setRecords(taskJobLogList);
        pagination.setActionUrl(WebUtils.getUrl("/pub/toTaskJobLogList.do", true, paramMap));

        return "toTaskJobLogList";
    }

    @Action(value="toTaskList")
    public String toTaskList() {
        try {
            String enabledStr = Constant.getInstance().getProperty("task_permission.enabled");
            if (enabledStr == null) {
                throw new Exception("缺失 task_permission.enabled 参数");
            }

            Boolean enabled = Boolean.parseBoolean(enabledStr);
            if (enabled) {
                List<String> users = new ArrayList<String>(Arrays.asList(Constant.getInstance().getProperty("task_permission.users").split(",")));
                PermUser permUser = getSessionUser();

                if (!users.contains(permUser.getUserName())) {
                    errorInfo = "你没有这个功能的操作权限";
                    return "errorPage";
                }
            }
        } catch (Exception e) {
            errorInfo = e.getMessage();
            return "errorPage";
        }
        Map<String, Object> paramMap = new HashMap<String, Object>();

        if (StringUtils.isNotBlank(taskId)) {
            paramMap.put("taskId", StringUtils.trimToEmpty(taskId));
        }
        if (StringUtils.isNotBlank(taskName)) {
            paramMap.put("taskName", StringUtils.trimToEmpty(taskName));
        }
        if (StringUtils.isNotBlank(webServiceUrl)) {
            paramMap.put("webServiceUrl", StringUtils.trimToEmpty(webServiceUrl));
        }
        if (StringUtils.isNotBlank(requestType)) {
            paramMap.put("requestType", StringUtils.trimToEmpty(requestType));
        }
        if (StringUtils.isNotBlank(parameter)) {
            paramMap.put("parameter", StringUtils.trimToEmpty(parameter));
        }
        if (StringUtils.isNotBlank(status)) {
            paramMap.put("status", status);
        }
        if (StringUtils.isNotBlank(available)) {
            paramMap.put("available", available);
        }
        if (StringUtils.isNotBlank(cycle)) {
            paramMap.put("cycle", cycle);
        }
        if (StringUtils.isNotBlank(jobNode)) {
            paramMap.put("jobNode", StringUtils.trimToEmpty(jobNode));
        }
        if (StringUtils.isNotBlank(owner)) {
            paramMap.put("owner", StringUtils.trimToEmpty(owner));
        }
        if (StringUtils.isNotBlank(lastRunStatus)) {
            paramMap.put("lastRunStatus", lastRunStatus);
        }
        if (StringUtils.isNotBlank(sort)) {
            paramMap.put("sort", sort);
        }
        if (StringUtils.isNotBlank(sortField)) {
            paramMap.put("sortField", sortField);
        }
        pagination = super.initPagination();

        Long totalRowCount = taskService.getTaskCount(paramMap);

        paramMap.put("_startRow", pagination.getFirstRow());
        paramMap.put("_endRow", pagination.getLastRow());

        taskList = taskService.getTaskList(paramMap);

        pagination.setTotalRecords(totalRowCount);
        pagination.setRecords(taskList);

        if (StringUtils.isNotBlank(refreshQuery)) {
            paramMap.put("refreshQuery", refreshQuery);
        }

        pagination.setActionUrl(WebUtils.getUrl("/pub/toTaskList.do", true, paramMap));

        return "toTaskList";
    }

    @Action(value="editTask")
    public String editTask() {

        if (task != null && task.getTaskId() != null) {
            task = taskService.getTask(task.getTaskId());
            weeks = new ArrayList<String>();
            if (task.getWeek() != null) {
                weeks.addAll(Arrays.asList(task.getWeek().split(",")));
            }
        } else {
            task = new Task();
            task.setCycleDimension(1L);
        }

        return "editTask";
    }


    @Action(value = "saveTask",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String saveTask() {
        try {

            boolean isToRun = false;//从非运行状态改为运行状态

            if (task.getTaskId() == null) {
                task.setCreateTime(new Date(System.currentTimeMillis()));
                task.setStatus(Task.TASK_STATUS.END.getCode());
            } else {
                Task dbTask = taskService.getTask(task.getTaskId());

                if (Task.TASK_STATUS.RUN.getCode().equals(task.getStatus())
                        && !Task.TASK_STATUS.RUN.getCode().equals(dbTask.getStatus())) {
                    isToRun = true;
                }
            }

            if (weeks != null) {
                String week_str = "";
                for (String week : weeks) {
                    week_str += week + ",";
                }
                if (week_str.length() > 0) {
                    week_str = week_str.substring(0, week_str.length() - 1);
                    task.setWeek(week_str);
                }
            }
            if (StringUtils.isNotBlank(task.getDescription()) && task.getDescription().length() > 800) {
                throw new Exception("“任务描述”不能超过800个字符");
            }

            //如果状态为“等待”，计算下次运行时间
            if (task.getStatus().equals(Task.TASK_STATUS.WAIT.getCode())) {
                task.setNextRunTime(TaskUtil.calculateNextRunTime(task));

            } else if (task.getAvailable().equals(Task.TASK_AVAILABLE.ENABLE.getCode())
                    && task.getStatus().equals(Task.TASK_STATUS.RUN.getCode())) {

                //如果从非运行状态改为运行状态，将下次执行时间改为当前时间，状态改为“等待”，下次轮询时运行
                if (isToRun) {
                    task.setStatus(Task.TASK_STATUS.WAIT.getCode());
                    task.setNextRunTime(new Date(System.currentTimeMillis()));
                }
            }
            taskService.saveTask(task, getSessionUser().getRealName());

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value = "batchModifyTask",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String batchModifyTask() {
        try {

            if (StringUtils.isBlank(taskIds)) {
                throw new Exception("任务ID为空");
            }

            if (weeks != null) {
                String week_str = "";
                for (String week : weeks) {
                    week_str += week + ",";
                }
                if (week_str.length() > 0) {
                    week_str = week_str.substring(0, week_str.length() - 1);
                    task.setWeek(week_str);
                }
            }
            if (StringUtils.isNotBlank(task.getDescription()) && task.getDescription().length() > 800) {
                throw new Exception("“任务描述”不能超过800个字符");
            }

            taskService.batchModifyTask(taskIds, task, getSessionUser().getRealName());

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value = "delTask",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String delTask() {
        try {
            if (StringUtils.isBlank(taskIds)) {
                throw new Exception("任务ID为空");
            }
            taskService.delTask(taskIds);

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value = "copyTask",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String copyTask() {
        try {
            if (StringUtils.isBlank(taskIds)) {
                throw new Exception("任务ID为空");
            }
            taskService.copyTask(taskIds, copyCount, taskNamePrefix, jobNode, serial, getSessionUser().getRealName());

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value = "enableDisableTask",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String enableDisableTask() {
        try {
            if (StringUtils.isBlank(taskIds)) {
                throw new Exception("任务ID为空");
            }
            taskService.enableDisableTask(taskIds, getSessionUser().getRealName());

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value = "immediatelyRunTask",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String immediatelyRunTask() {
        try {
            if (StringUtils.isBlank(taskIds)) {
                throw new Exception("任务ID为空");
            }
            taskService.immediatelyRunTask(taskIds, getSessionUser().getRealName());

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value = "testCron",
            results = @Result(type = "json", name = "success", params = {"includeProperties", "jsonMap.*"})
    )
    public String testCron() {
        try {
            if (task == null || StringUtils.isBlank(task.getCronExpression())) {
                throw new Exception("请填写Cron表达式");
            }

            StringBuffer info = new StringBuffer();

            try {
                CronTrigger cronTrigger = new CronTrigger();
                cronTrigger.setCronExpression(task.getCronExpression());

                int times = 10;
                List<Date> dates = TriggerUtils.computeFireTimes(cronTrigger, null, times);
                for (Date date : dates) {
                    info.append(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")).append("\n");
                }
                info.insert(0, "最近" + times + "次执行时间:\n\n");

                jsonMap.put("info", info.toString());

            } catch (Exception e) {
                throw new Exception("Cron表达式错误");
            }

            jsonMap.put("status", SUCCESS);
        } catch (Exception e) {
            LOG.error(e);
            jsonMap.put("status", e.getMessage());
        }
        return SUCCESS;
    }

    @Action(value="importTaskList")
    public String importTaskList() {
        TaskXmlRoot root = null;
        InputStream is = null;
        try {
            is = new FileInputStream(upload);
            root = TaskXmlRoot.getInstance(is);
        } catch (Exception e) {
            e.printStackTrace();
            message = "导入文件有误！";
        } finally {
            IOUtils.closeQuietly(is);
        }

        if (root != null) {
            int insertCount = 0;
            for (TaskXmlModel model : root.getTasks()) {
                Task old = taskService.getTask(model.getTaskId());
                if (old == null) {
                    model.setTaskId(null);
                    model.setCreateTime(new Date());
                    model.setStatus(Task.TASK_STATUS.END.toString());
                    taskService.saveTask(model, getSessionUser().getRealName());
                    insertCount++;
                }
            }
            message = "新增任务" + insertCount + "条。";
        }
        Map<String, Object> paramMap = new HashMap<String, Object>();
        pagination = super.initPagination();
        Long totalRowCount = taskService.getTaskCount(paramMap);
        paramMap.put("_startRow", pagination.getFirstRow());
        paramMap.put("_endRow", pagination.getLastRow());

        taskList = taskService.getTaskList(paramMap);

        pagination.setTotalRecords(totalRowCount);
        pagination.setRecords(taskList);
        pagination.setActionUrl(WebUtils.getUrl("/pub/toTaskList.do", true, paramMap));

        return "toTaskList";
    }

    @Action(value="exportTaskListXML")
    public void exportTaskListXML() throws Exception {
        List<Task> taskList = taskService.getTaskListByInTaskId(selects);
        if (taskList.size() == 0) {
            return;
        } else {
            TaskXmlRoot root = new TaskXmlRoot();
            root.setTasks(new ArrayList<TaskXmlModel>());
            for (Task task : taskList) {
                TaskXmlModel model = TaskXmlModel.createInstance(task);
                root.getTasks().add(model);
                insertTaskOperationLog(task);

            }
            ServletActionContext.getResponse().setContentType("application/x-download");
            ServletActionContext.getResponse().addHeader("Content-Disposition", "attachment;filename=TaskModel_" + new SimpleDateFormat("yyyy/MM/dd-hh:mm").format(new Date()) + ".xml");
            root.response(ServletActionContext.getResponse().getOutputStream());
        }
    }

    public void insertTaskOperationLog(Task task) {
        String logType = "TASK_EXPORT";
        String typeName = "导出任务";
        String logInfo = "导出任务:" + JSONObject.fromObject(task).toString();
        taskOperationLogService.insert(task.getTaskId(), logType, typeName, logInfo, getSessionUser().getRealName());
    }

    private void initPageSize() {
        paramMap.put("skipResults", pagination.getFirstRow() - 1);
        paramMap.put("maxResults", pagination.getLastRow());
    }

    public List<TaskOperationLog> getTaskOperationLogList() {
        return taskOperationLogList;
    }

    public void setTaskOperationLogList(List<TaskOperationLog> taskOperationLogList) {
        this.taskOperationLogList = taskOperationLogList;
    }

    public Map getParamMap() {
        return paramMap;
    }

    public void setParamMap(Map paramMap) {
        this.paramMap = paramMap;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getAvailable() {
        return available;
    }

    public void setAvailable(String available) {
        this.available = available;
    }

    public List<Task> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<Task> taskList) {
        this.taskList = taskList;
    }

    public TaskService getTaskService() {
        return taskService;
    }

    public void setTaskService(TaskService taskService) {
        this.taskService = taskService;
    }

    public Task getTask() {
        return task;
    }

    public void setTask(Task task) {
        this.task = task;
    }

    public Map<String, Object> getJsonMap() {
        return jsonMap;
    }

    public void setJsonMap(Map<String, Object> jsonMap) {
        this.jsonMap = jsonMap;
    }

    public List<String> getWeeks() {
        return weeks;
    }

    public void setWeeks(List<String> weeks) {
        this.weeks = weeks;
    }

    public String getTaskIds() {
        return taskIds;
    }

    public void setTaskIds(String taskIds) {
        this.taskIds = taskIds;
    }

    public List<TaskJobLog> getTaskJobLogList() {
        return taskJobLogList;
    }

    public void setTaskJobLogList(List<TaskJobLog> taskJobLogList) {
        this.taskJobLogList = taskJobLogList;
    }

    public TaskJobLog getTaskJobLog() {
        return taskJobLog;
    }

    public void setTaskJobLog(TaskJobLog taskJobLog) {
        this.taskJobLog = taskJobLog;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getCycle() {
        return cycle;
    }

    public void setCycle(String cycle) {
        this.cycle = cycle;
    }

    public String getWebServiceUrl() {
        return webServiceUrl;
    }

    public void setWebServiceUrl(String webServiceUrl) {
        this.webServiceUrl = webServiceUrl;
    }

    public String getRequestType() {
        return requestType;
    }

    public void setRequestType(String requestType) {
        this.requestType = requestType;
    }

    public String getParameter() {
        return parameter;
    }

    public void setParameter(String parameter) {
        this.parameter = parameter;
    }

    public String getErrorInfo() {
        return errorInfo;
    }

    public void setErrorInfo(String errorInfo) {
        this.errorInfo = errorInfo;
    }

    public Integer getCopyCount() {
        return copyCount;
    }

    public void setCopyCount(Integer copyCount) {
        this.copyCount = copyCount;
    }

    public String getSelects() {
        return selects;
    }

    public void setSelects(String selects) {
        this.selects = selects;
    }

    public String getMessage() {
        return message;
    }

    public void setUpload(File upload) {
        this.upload = upload;
    }

    public TaskOperationLogService getTaskOperationLogService() {
        return taskOperationLogService;
    }

    public void setTaskOperationLogService(TaskOperationLogService taskOperationLogService) {
        this.taskOperationLogService = taskOperationLogService;
    }

    public String getTaskJobLogId() {
        return taskJobLogId;
    }

    public void setTaskJobLogId(String taskJobLogId) {
        this.taskJobLogId = taskJobLogId;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public Constant.TIME_CONSUMING_MILLIS getMaxTimeConsuming() {
        return maxTimeConsuming;
    }

    public void setMaxTimeConsuming(Constant.TIME_CONSUMING_MILLIS maxTimeConsuming) {
        this.maxTimeConsuming = maxTimeConsuming;
    }

    public Constant.TIME_CONSUMING_MILLIS getMinTimeConsuming() {
        return minTimeConsuming;
    }

    public void setMinTimeConsuming(Constant.TIME_CONSUMING_MILLIS minTimeConsuming) {
        this.minTimeConsuming = minTimeConsuming;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getSortField() {
        return sortField;
    }

    public void setSortField(String sortField) {
        this.sortField = sortField;
    }

    public String getJobNode() {
        return jobNode;
    }

    public void setJobNode(String jobNode) {
        this.jobNode = jobNode;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getSerial() {
        return serial;
    }

    public void setSerial(String serial) {
        this.serial = serial;
    }

    public String getTaskNamePrefix() {
        return taskNamePrefix;
    }

    public void setTaskNamePrefix(String taskNamePrefix) {
        this.taskNamePrefix = taskNamePrefix;
    }

    public String getResultRunStatus() {
        return resultRunStatus;
    }

    public void setResultRunStatus(String resultRunStatus) {
        this.resultRunStatus = resultRunStatus;
    }

    public String getLastRunStatus() {
        return lastRunStatus;
    }

    public void setLastRunStatus(String lastRunStatus) {
        this.lastRunStatus = lastRunStatus;
    }

    public String getRefreshQuery() {
        return refreshQuery;
    }

    public void setRefreshQuery(String refreshQuery) {
        this.refreshQuery = refreshQuery;
    }
}
